package controller;

import service.PhoneService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/removePhone.do")
public class RemovePhoneServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获得id
        String id = req.getParameter("id");
        PhoneService phoneService = new PhoneService();
        //删除宠物
        try {
            phoneService.deletePhoneById(Integer.valueOf(id));
            //跳转查询宠物
            resp.sendRedirect("/selectAllPhone.do");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
